package com.ntd.study.base.network;

import java.io.*;
import java.net.Socket;

/**
 * socket 客户端demo
 */
public class DemoSocketClient {

    public static void main(String[] args) throws IOException {
        Socket client = new Socket("localhost", 33001);
        DataOutputStream out = new DataOutputStream(client.getOutputStream());
        out.writeUTF("Hello from " + client.getLocalSocketAddress());
        DataInputStream in = new DataInputStream(client.getInputStream());
        System.out.println("服务器响应： " + in.readUTF());
        client.close();
    }
}
